package cn.shlbysj.demo.controller;

import cn.shlbysj.demo.common.ConstansUtil;
import cn.shlbysj.demo.common.PageResult;
import cn.shlbysj.demo.common.Result;
import cn.shlbysj.demo.service.IArticleService;
import cn.shlbysj.demo.service.ITitleInfoService;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/goood")
@Api("客户好评模块")
public class GoodInfoController {
    @Autowired
    private ITitleInfoService titleInfoService;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ApiOperation(httpMethod = "GET", value = "获取好评的分页接口")
    @ResponseBody
    public Result list(HttpServletRequest request,
                       @ApiParam(name="page",value="当前页",required = true)@RequestParam(value = "page",required = true) Integer page ,
                       @ApiParam(name="rows",value="每页显示多少条",required = true)@RequestParam(value = "rows",required = true) Integer rows){
        try {
            PageResult pageResult = titleInfoService.findPage(page,rows);
            return new Result(ConstansUtil.RESULT_SUCCESS,ConstansUtil.RESULT_SUCCESS_MESSAGE, JSON.toJSONString(pageResult),"");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(ConstansUtil.RESULT_FAIL,ConstansUtil.RESULT_FAIL_MESSAGE,"","");
        }

    }
}
